<?php

use think\Facade\Route;
use think\Facade\Env;

Route::domain(Env::get('app.api_url'), function () {
    header("Access-Control-Allow-Origin: *");
    header('Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE, HEAD, PATCH');
    header("Access-Control-Allow-Headers: token,tokens,language, Origin, X-Requested-With, Content-Type, Accept");
    Route::miss(function () {
        $result = [
            'code' => 1,
            'msg'  => '接口错误',
            'time' => time(),
            'data' => [],
        ];
        return json($result);
        exit();
    });
    Route::group('User', function () {
        Route::post('login', '/login'); //登录
        Route::rule('address', '/address'); //地址管理
        Route::post('address_del', '/address_del'); //地址管理
        Route::rule('cart', '/cart'); //地址管理
        Route::post('cart_del', '/cart_del'); //地址管理
        Route::rule('collect', '/collect'); //地址管理
        Route::post('collect_del', '/collect_del'); //地址管理
        Route::post('putorder', '/putorder'); //提交订单
        Route::get('orderlist', '/orderlist'); //订单列表
        Route::get('orderdetail', '/orderdetail'); //订单列表
        Route::get('business', '/business'); //订单列表
        Route::get('info', '/info'); //提交订单
        Route::post('orderstatus', '/orderstatus'); //提交订单
        Route::post('orderpay', '/orderpay'); //提交订单
        Route::get('qrcode', '/qrcode'); //提交订单
        Route::post('buyuser', '/buyuser'); //提交订单
        Route::rule('goods', '/goods'); //提交订单
        Route::get('getgoods', '/getgoods'); //提交订单
        Route::get('getclass', '/getclass'); //提交订单
        Route::get('getbusiness', '/getbusiness'); //提交订单
        Route::get('getgoodsdetail', '/getgoodsdetail'); //提交订单
        // Route::get('getonecart', '/getonecart'); //提交订单
    })->prefix('User');
    Route::group('Other', function () {
        Route::get('addressjson', '/addressjson'); //获取本地地址库
        Route::get('others', '/others'); //平台分类
        Route::get('banner', '/banner'); //轮播图
        Route::get('annous', '/annous'); //轮播图
        Route::get('getstreet', '/getstreet'); //轮播图
        Route::get('pgoods', '/pgoods'); //轮播图
        Route::get('getpgoodsdetail', '/getpgoodsdetail'); //轮播图
        Route::post('putporder', '/putporder'); //轮播图
        Route::get('porderlist', '/porderlist'); //轮播图
        Route::get('porderdetail', '/porderdetail'); //轮播图
        Route::rule('oss', '/oss'); //商品列表
        Route::rule('getopenid', '/getopenid'); //商品列表
        Route::rule('callback', '/callback'); //商品列表
        Route::rule('callback2', '/callback2'); //商品列表
    })->prefix('Other');
})->bind('api')->prefix('api');
